package org.sudoku.solver;

/**
 * Solver interface for inference-based sudoku solvers.
 * 
 * @author shivkumar cm
 * 
 */
public interface ISolver {

	/**
	 * Reads a problem from an array of strings.
	 */
	void readProblem(String[] problem);

	/**
	 * Sets the given digit to the position [row, col]
	 */
	void set(int row, int col, int digit);

	/**
	 * @return the digit at position [row, col] if it is known.
	 */
	int get(int row, int col);
	
	/**
	 * @return true if digit at position [row, col] is known
	 */
	boolean isKnown(int row, int col);

	/**
	 * Infers digits from the current state of the grid. The inferred values are
	 * saved separately. They are not applied instantaneously to avoid
	 * triggerring of new inferences.
	 * 
	 * @return true if one or more cells are inferred
	 */
	boolean infer();

	/**
	 * @return Array of inferences which are triplets of the form [row, col,
	 *         digit].
	 */
	int[][] getInferences();

	/**
	 * Applies the inferences to the grid to complete one step in solving the
	 * problem. No change if infer is not invoked before this call.
	 */
	void applyInferences();

	/**
	 * Infers and then applies. Signifies one complete step in solving the
	 * problem.
	 * 
	 * @return true if one or more cells are inferred
	 */
	boolean inferAndApply();

	/**
	 * Keeps solving in steps until the problem is solved or there is no
	 * progress. Returns the number of steps to solve or before halt.
	 * 
	 * @return
	 */
	int solve();

	/**
	 * Pretty prints the grid.
	 */
	void prettyPrint();

	/**
	 * @return true if the problem is solved
	 */
	boolean solved();

	// void setVerbose(boolean value);

}
